<#include "/admin/common/include/html_head.html"> <#include
"/admin/common/include/sysparam.html"> <#include
"/admin/common/include/pagination.html">
<div class="row-fluid">
	<div class="span12">
		<!-- BEGIN EXTRAS PORTLET-->
		<div class="portlet box">
			<div class="portlet-title">
				<div class="caption">
					<h5>内容编辑</h5>
				</div>
			</div>
			<div class="portlet-body form">
				<div class="alert alert-error " id="errtip" style="display: none;"></div>

				<!-- BEGIN FORM-->
				<form action="${contextPath}/block/save.op" id="bannerAddForm"
					class="form-horizontal" method="post">
					<input type="hidden" name="id" value="${(bean.id)?if_exists}" />
					<div class="control-group">
						<label class="control-label">分类编码<span class="required">*</span></label>
						<div class="controls"><@select2 paramCode=groupKeyCode
							value=(bean.groupKeyId)?if_exists item=' id="groupKeyId"
							name="groupKeyId" require="true" datatype="require"
							msg="分类编码不能为空" readOnly'/></div>
					</div>
					<div class="control-group">
						<label class="control-label">内容主题<span class="required">*</span></label>
						<div class="controls">
							<input type="text" name="name" id="name" require="true"
								datatype="require" msg="栏目名称不能为空" class="span3 m-wrap"
								value="${(bean.name)?if_exists}" />
						</div>
					</div>

					<div class="control-group">
						<label class="control-label">内容图片</label>
						<div class="controls">
							<#if bean?? && bean.imageUrl ?? > <img
								src="${contextPath}${(bean.imageUrl)?if_exists}" width="150"
								height="150" id="imgShow" alt="Photo" /> <#else> <img
								src="${contextPath}/common/image/default-pic.png" width="150"
								height="150" id="imgShow" /> </#if>

						</div>
					</div>
					<div class="control-group">
						<label class="control-label"></label>
						<div class="controls">
							<span class="btn  fileinput-button"> <i
								class="icon-plus icon-white"></i> <span>选择文件...</span> <input
								type="file" id="upfile1" name="upfile1" />
							</span> <input type="hidden" id="imageUrl" name="imageUrl"
								value="${(bean.imageUrl)?if_exists}" /> <a class="btn start"
								onclick="uploadNavPic();"> <i class="icon-upload icon-white"></i>
								<span>上传</span>
							</a> <br> <span class="alert alert-error" id="upfile1_error_tip"
								style="display: none;"></span>
							<div class="alert alert-success" id="upfile1_detail"
								style="display: none;">
								<div class="fileName">
									文件名称:<span></span>
								</div>
								<div class="fileSize">
									文件大小:<span></span>
								</div>
							</div>

						</div>
					</div>
					<div class="control-group">
						<label class="control-label">链接类型&nbsp;&nbsp;</label>
						<div class="controls"><@select paramCode=blockLinkType
							value=(bean.linkType)?if_exists item=' name="linkType"
							require="true" datatype="require" msg="链接类型不能为空"'/></div>
					</div>
					<div class="control-group">
						<label class="control-label">资源模板&nbsp;&nbsp;</label>
						<div class="controls">
							<@select2 paramCode=templateIdCode
							value=(bean.templateId)?if_exists item=' name="templateId"
							 '/>
						</div>
					</div>
					<div class="control-group">
						<label class="control-label">外链接&nbsp;&nbsp;</label>
						<div class="controls">
							<textarea class="span12  m-wrap" rows="2" id="linkUrl"
								name="linkUrl">${(bean.linkUrl)?if_exists}</textarea>
						</div>
					</div>
					
					<div class="control-group">
						<label class="control-label">排位&nbsp;&nbsp;</label>
						<div class="controls">
							<input name="rank" type="text" class="span2 m-wrap"
								value="${(bean.rank)?if_exists}" require="true"
								datatype="require" msg="排位不能为空" />
						</div>
					</div>
					<div class="control-group">
						<label class="control-label">详细描述&nbsp;&nbsp;</label>
						<div class="controls">
							<textarea class="span12" name="shortDescEdit" rows="20"
								id="shortDescEdit">${(bean.shortDesc)?if_exists}</textarea>
							<input type="hidden" id="shortDesc" name="shortDesc"
								value='${(bean.shortDesc)?if_exists}' type="text"   />

						</div>
					</div>

					<div class="control-group">
						<label class="control-label">是否有效<span class="required">*</span></label>
						<div class="controls"><@select2 paramCode=iseffCode
							value=(bean.iseff)?if_exists item=' name="iseff" require="true"
							datatype="require" msg="是否有效不能为空"'/></div>
					</div>

					<div class="form-actions">
						<button type="button" id="banner_save_btn" class="btn blue">保存</button>
						<button type="button" id="banner_return_btn" class="btn ">返回</button>
					</div>
				</form>

			</div>
			<!-- END EXTRAS PORTLET-->
		</div>
	</div>
</div>

<script>
	function uploadNavPic() {
		ajax.upload({
			fileEleId : 'upfile1',
			filePathId : 'imageUrl',
			successFn : function(data) {
				var isImg = /\.(gif|jpg|jpeg|png|GIF|JPG|PNG)$/
						.test(data.result.webfilePath);
				if (isImg)
					$('#imgShow').attr("src", data.result.webfilePath);
			}
		}) 
	}
	
	
	  
	jQuery(document)
			.ready(
					function() {
						
						var oCKeditor = CKEDITOR.replace( 'shortDescEdit',{ height: '340px' } );

						tableAction
								.initSaveAction({
									formId : 'bannerAddForm',
									queryUrl : '${contextPath}/block/show.op?_QUERY_n_eq_group_key_id='
											+ $('#groupKeyId').val(),
									saveUrl : '${contextPath}/block/save.op',
									saveBtnId : 'banner_save_btn',
									beforeSaveFn : function() {
										var editor = CKEDITOR.instances.shortDescEdit;
										$("#shortDesc").val(editor.getData());
									}
								});

						$("#banner_return_btn")
								.bind(
										"click",
										function() {
											var url = '${contextPath}/block/show.op?_QUERY_n_eq_group_key_id='
													+ $('#groupKeyId').val();
											mainFrame.addContainer(url);
										});

					});
</script>
<#include "/admin/common/include/html_bottom.html">
